package com.ruoyi.report_tg.controller;

import java.util.List;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;

import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaCheckLogin;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.core.validate.QueryGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.report_tg.domain.vo.TdczbjlbyBsInfoVo;
import com.ruoyi.report_tg.domain.bo.TdczbjlbyBsInfoBo;
import com.ruoyi.report_tg.service.ITdczbjlbyBsInfoService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 土的承载比(CBR)记录一
 *
 * @author zyb
 * @date 2024-05-24
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/report_tg/tgTdczbjlbyBsInfo")
public class TdczbjlbyBsInfoController extends BaseController {

    private final ITdczbjlbyBsInfoService iTdczbjlbyBsInfoService;

    /**
     * 查询土的承载比(CBR)记录一列表
     */
    @SaCheckLogin
    @GetMapping("/list")
    public TableDataInfo<TdczbjlbyBsInfoVo> list(TdczbjlbyBsInfoBo bo, PageQuery pageQuery) {
        return iTdczbjlbyBsInfoService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出土的承载比(CBR)记录一列表
     */
    @SaCheckLogin
    @Log(title = "土的承载比(CBR)记录一", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(TdczbjlbyBsInfoBo bo, HttpServletResponse response) {
        List<TdczbjlbyBsInfoVo> list = iTdczbjlbyBsInfoService.queryList(bo);
        ExcelUtil.exportExcel(list, "土的承载比(CBR)记录一", TdczbjlbyBsInfoVo.class, response);
    }

    /**
     * 获取土的承载比(CBR)记录一详细信息
     *
     * @param excelId 主键
     */
    @SaCheckLogin
    @GetMapping("/{excelId}")
    public R<TdczbjlbyBsInfoVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable Long excelId) {
        return R.ok(iTdczbjlbyBsInfoService.queryById(excelId));
    }

    /**
     * 新增土的承载比(CBR)记录一
     */
    @SaCheckLogin
    @Log(title = "土的承载比(CBR)记录一", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody TdczbjlbyBsInfoBo bo) {
        return toAjax(iTdczbjlbyBsInfoService.insertByBo(bo));
    }

    /**
     * 修改土的承载比(CBR)记录一
     */
    @SaCheckLogin
    @Log(title = "土的承载比(CBR)记录一", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody TdczbjlbyBsInfoBo bo) {
        return toAjax(iTdczbjlbyBsInfoService.updateByBo(bo));
    }

    /**
     * 删除土的承载比(CBR)记录一
     *
     * @param excelIds 主键串
     */
    @SaCheckLogin
    @Log(title = "土的承载比(CBR)记录一", businessType = BusinessType.DELETE)
    @DeleteMapping("/{excelIds}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] excelIds) {
        return toAjax(iTdczbjlbyBsInfoService.deleteWithValidByIds(Arrays.asList(excelIds), true));
    }
}
